<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>

    <h1 id="h1"></h1>

    <script>


        // 登录原理：
        // 如果persons中含有对应的用户名和密码则提示登录成功，否则提示用户名和密码错误

        let persons = [
            { "username": "xiaoming1", "password": "1111" },
            { "username": "xiaoming2", "password": "222" },
            { "username": "xiaoming3", "password": "33333" }
        ]

        let user = { username: "admin1", password: "12345" }
        persons.some(item => item.username == user.username && item.password == user.password ? h1.innerText = '登录成功' : h1.innerText = '用户名或密码错误'

       )
    </script>
</body>

</html>